#ifndef GAMETD_PANEL_H
#define GAMETD_PANEL_H

#include <SDL.h>

class Panel {
public:
    Panel();
    ~Panel();
    void Show();
    void SetIdxTile(const SDL_Point &idx);
    void SetCenterPos(const SDL_Point &pos);
    void OnInput(const SDL_Event &event);
    virtual void OnUpdate(SDL_Renderer *renderer);
    virtual void OnRender(SDL_Renderer *renderer);

protected:
    virtual void OnClickTopArea() = 0;
    virtual void OnClickLeftArea() = 0;
    virtual void OnClickRightArea() = 0;

protected:
    enum class HoveredTarget {
        None,
        Top,
        Left,
        Right
    };

protected:
    bool visible = false;
    SDL_Point idxTileSelected{};
    SDL_Point centerPos = {0};
    SDL_Texture *texIdle = nullptr;
    SDL_Texture *texHoveredTop = nullptr;
    SDL_Texture *texHoveredLeft = nullptr;
    SDL_Texture *texHoveredRight = nullptr;
    SDL_Texture *texSelectCursor = nullptr;
    int valTop = 0, valLeft = 0, valRight = 0;
    HoveredTarget hoveredTarget = HoveredTarget::None;

private:
    const int sizeButton = 48;
    const int width = 144, height = 144;
    const SDL_Point offsetTop = {48, 6};
    const SDL_Point offsetLeft = {8, 80};
    const SDL_Point offsetRight = {90, 80};
    const SDL_Point offsetShadow = {3, 3};
    const SDL_Color colorTextBackground = {175, 175, 175, 255};
    const SDL_Color colorTextForeground = {255, 255, 255, 255};

    int widthText = 0, heightText = 0;
    SDL_Texture *texTextBackground = nullptr;
    SDL_Texture *texTextForeground = nullptr;
};

#endif //GAMETD_PANEL_H
